package com.wyf.cnbeta;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.List;

/**
 * Created by Administrator on 2017/10/30.
 */

public class IndexAdapter extends BaseAdapter {
    private Context context;
    private  List<IndexModel.ResultBean.ListBean> list;
    public IndexAdapter(Context context,  List<IndexModel.ResultBean.ListBean> list) {
        this.context = context;
        this.list = list;
    }



    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View root = LayoutInflater.from(context).inflate(R.layout.item_index,null);

        ImageView img = root.findViewById(R.id.index_img_thumb);
        Glide.with(context).load(list.get(i).getThumb()).diskCacheStrategy(DiskCacheStrategy.ALL).thumbnail(0.1f).into(img);
        TextView title = root.findViewById(R.id.index_title);
        title.setText(""+list.get(i).getTitle());
        TextView time = root.findViewById(R.id.index_time);
        time.setText(list.get(i).getInputtime());
        TextView subtitle = root.findViewById(R.id.index_subtitle);
        subtitle.setText(list.get(i).getLabel());

        return root;
    }
}
